package com.example.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PreDestroy;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@RestController
@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@PreDestroy
	public void preDestroy() {
		log.info("下线了");
	}

	@GetMapping("/get")
	public String get() {
		return "get";
	}

	@GetMapping("/oom")
	public String oom() {
		new Thread(() -> {
			List<Byte[]> l = new ArrayList<>();
			while (true) {
				l.add(new Byte[1024 * 1024]);
			}
		}).start();
		return "oom";
	}
}
